<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<kd-card
  [initialized]="isInitialized()"
  [expandable]="true"
>
  <div
    title
    i18n
  >
    Global settings
  </div>
  <div content>
    <p i18n>Global settings are stored in config map, so all of them are applied for every instance of the app.</p>
    <br />
    <form [formGroup]="form">
      <kd-settings-entry
        key="Cluster name"
        i18n-key
        desc="Cluster name appears in the browser window title if it is set."
        i18n-desc
      >
        <mat-form-field fxFlex>
          <input
            [formControlName]="Controls.ClusterName"
            name="clusterName"
            i18n-placeholder
            placeholder="Cluster name"
            type="text"
            matInput
          />
        </mat-form-field>
      </kd-settings-entry>

      <kd-namespace-settings [formControlName]="Controls.NamespaceSettings"> </kd-namespace-settings>

      <kd-settings-entry
        key="Items per page"
        i18n-key
        desc="Max number of items that can be displayed on every list view."
        i18n-desc
      >
        <div fxFlex>
          <mat-slider
            [formControlName]="Controls.ItemsPerPage"
            color="primary"
            min="5"
            max="50"
            step="5"
            fxFlex
          >
          </mat-slider>
          <div
            class="kd-slider-value kd-muted"
            fxFlexAlign=" center"
          >
            {{ settings.itemsPerPage }}
          </div>
        </div>
      </kd-settings-entry>
      <kd-settings-entry
        key="Labels limit"
        i18n-key
        desc="Max number of labels that are displayed by default on most views."
        i18n-desc
      >
        <div fxFlex>
          <mat-slider
            [formControlName]="Controls.LabelsLimit"
            color="primary"
            min="1"
            max="10"
            step="1"
            fxFlex
          >
          </mat-slider>
          <div
            class="kd-slider-value kd-muted"
            fxFlexAlign=" center"
          >
            {{ settings.labelsLimit }}
          </div>
        </div>
      </kd-settings-entry>
      <kd-settings-entry
        key="Logs auto-refresh time interval"
        i18n-key
        desc="Number of seconds between every auto-refresh of logs."
        i18n-desc
      >
        <div fxFlex>
          <mat-slider
            [formControlName]="Controls.LogsAutorefreshInterval"
            color="primary"
            min="1"
            max="10"
            step="1"
            fxFlex
          >
          </mat-slider>
          <span
            class="kd-slider-value kd-muted"
            fxFlexAlign=" center"
          >
            {{ settings.logsAutoRefreshTimeInterval }}
          </span>
        </div>
      </kd-settings-entry>
      <kd-settings-entry
        key="Resource auto-refresh time interval"
        i18n-key
        desc="Number of seconds between every auto-refresh of every resource. Set 0 to disable."
        i18n-desc
      >
        <div fxFlex>
          <mat-slider
            [formControlName]="Controls.ResourceAutorefreshInterval"
            color="primary"
            min="0"
            max="60"
            step="5"
            fxFlex
          >
          </mat-slider>
          <span
            class="kd-slider-value kd-muted"
            fxFlexAlign=" center"
          >
            {{ settings.resourceAutoRefreshTimeInterval }}
          </span>
        </div>
      </kd-settings-entry>
      <kd-settings-entry
        key="Disable access denied notification"
        i18n-key
        desc="Hides all access denied warnings in the notification panel."
        i18n-desc
      >
        <div
          fxFlex
          fxLayoutAlign=" center"
        >
          <mat-slide-toggle
            color="primary"
            name="disableAccessDeniedNotifications"
            [formControlName]="Controls.DisableAccessDeniedNotification"
          >
          </mat-slide-toggle>
        </div>
      </kd-settings-entry>
      <br /><br />
      <button
        [disabled]="!canSave()"
        (click)="save()"
        color="primary"
        mat-raised-button
        i18n
      >
        Save
      </button>
      <button
        type="button"
        (click)="reload()"
        color="primary"
        mat-raised-button
        i18n
      >
        Reload
      </button>
    </form>
  </div>
</kd-card>
